package com.joven.core.conf;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author joven_wong
 * 2021/7/6 14:29
 */
@EnableSwagger2
@Configuration
public class Swagger2Config {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.joven.core.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("Spring Cloud Alibaba 整合 Swagger2 构建RESTful API")
                .description("---> 详情关注gitee ")
//                .termsOfServiceUrl("https://edu.csdn.net/lecturer/995")
                .contact(new Contact("joven",
                        "https://gitee.com/joven_wong",
                        "joven2500@163.com"))
//                .license("The Apache License")
//                .licenseUrl("http://www.baidu.com")
                .version("1.0")
                .build();
    }

}
